home *** CD-ROM | disk | FTP | other *** search
- /*************************************************************************************************
- *
- *
- * ObjectMacZapp -- a standard Mac OOP application template
- *
- *
- *
- * ZExtraDialogItems.h -- some other kinds of dialog item objects
- *
- *
- * © 1997, Graham Cox
- *
- *
- *
- *************************************************************************************************/
-
- #pragma once
-
- #ifndef __ZEXTRADIALOGITEMS__
- #define __ZEXTRADIALOGITEMS__
-
-
- #include "ZAdvancedDialog.h"
-
- // types of lines:
-
- typedef enum
- {
- plainLine,
- patternLine,
- raised3DLine,
- etched3DLine
- }
- LineType;
-
- // line class- used to draw straight lines in dialogs
-
- class ZLineDialogItem : public ZDialogItem
- {
- protected:
- LineType itsType;
- short patIndex;
-
- public:
- ZLineDialogItem( ZDialog* aDialog, short item );
-
- virtual void DrawItem();
- virtual void InitItem( const long param1, const long param2 );
- };
-
-
- #define kLineItemMagicString 'LINE'
-
- // icon hiliting style
-
- typedef enum
- {
- iconHiliteBoldBorder = 1, // draw bold box around icon
- iconHiliteDarken = 2, // "select" the icon
- iconHiliteInvertTitle = 4, // invert the title string
- iconHiliteInvertCell = 8, // invert the entire cell (but not icon)
- iconHiliteUseHColour = 16, // use hilite colour for inversion
- iconDefaultHilite = iconHiliteDarken + iconHiliteInvertTitle
- }
- IconHilite;
-
- // n.b. modes can be combined together if desired. Default is darken + invert title
-
-
- // icon listbox class- used to create listboxes with icons, based on 'ICLB' resources
-
- class ZIconListBox : public ZListDialogItem
- {
- protected:
- Boolean showTitles; // show icon titles?
- Boolean smallIcons; // TRUE if we use 16 x 16 rather than 32 x 32
- IconHilite iHilite; // how to hilite the icons
-
-
- public:
- ZIconListBox( ZDialog* aDialog, short item );
- ~ZIconListBox();
-
- virtual void InitItem( const long param1, const long param2 );
-
- inline IconHilite GetHiliteStyle() { return iHilite; };
- inline Boolean ShowTitles() { return showTitles; };
-
- protected:
- virtual void MakeMacList( const short listTemplateID = 0 );
- virtual void InstallIconLDEF();
- virtual void AddIconCells( const short templateID );
- virtual void DisposeIconCells();
- };
-
- // template for icon list box resource ('ICLB')
-
- #if PRAGMA_ALIGN_SUPPORTED
- #pragma options align=mac68k
- #endif
-
- typedef struct
- {
- short resID; // res ID of icon
- short iconType; // type of icon (ICON, cicn or ICN#)
- short nameIndex; // index into STR# for title
- }
- IconRec;
-
- typedef struct
- {
- short hiliteStyle; // hiliting method to use (same as above)
- short hSpacing; // spacing between horizontal icons
- short vSpacing; // spacing between vertical icons
- short titleListResID; // res id of STR# with titles
- Boolean addTitles : 1; // show titles with icons
- Boolean useResName : 1; // use icon's res name for title
- Boolean useSmallIcons : 1; // use small icons instead of large
- Boolean unused : 5; // reserved
- short numIcons; // number of icons in following array
- IconRec icons[1]; // variable length array of icon defs
- }
- IconListBox, *IconListBoxPtr, **IconListBoxHdl;
-
- #define kIconListTemplateResType 'ICLB'
- #define kIconListboxMagicString 'ICLB'
-
- // icon types in template
-
- #define kBasicIcon 0 // uses 'ICON' resource
- #define kColourIcon 1 // uses 'cicn' resource
- #define kFamilyIcon 2 // uses 'ICN#', 'icl8', etc. resources
-
-
- #if PRAGMA_ALIGN_SUPPORTED
- #pragma options align=reset
- #endif
-
- // icon types
-
- typedef enum
- {
- IconPlain,
- IconColour,
- IconFamily,
- IconSuite,
- IconIndexed
- }
- IconType;
-
- // internal structure kept in list cells:
-
- typedef struct
- {
- IconType iType; // icon's type (colour, family, etc)
- Handle theIcon; // handle to the icon if loaded
- short iconID; // resource ID of the icon
- long userData; // reserved for your own use if needed
- Str31 title; // icon's title string, if any
- }
- IconInfo;
-
- // class for scrolling textbox dialog item:
-
- class ZScrollingTextBox : public ZDialogItem
- {
- protected:
- TEHandle te; // textEdit record
- ControlHandle scroll; // scrollbar
- Boolean editable; // TRUE if editable text
- short resID; // res ID of TEXT/styl resource
- short lineHeight; // height of a line
- short pageHeight; // height of a "page"
-
- public:
- ZScrollingTextBox( ZDialog* aDialog, short item );
- ~ZScrollingTextBox();
-
- // overrides:
- virtual void InitItem( const long param1, const long param2 );
- virtual void DrawItem();
- virtual void ClickItem( const Point where, const short modifiers );
- virtual void AdjustCursor( const Point where, const short modifiers );
- virtual void Activate( const Boolean isActive );
- virtual void Type( const char theKey );
- virtual void Idle();
- virtual void BecomeHandler( Boolean isBecoming );
-
- virtual void DoCut();
- virtual void DoCopy();
- virtual void DoPaste();
- virtual void DoClear();
- virtual void DoSelectAll();
- virtual Boolean CanPasteType();
- virtual void UpdateMenus();
-
- // original methods:
- virtual void SetText( Handle textH, Handle styleH = NULL );
- virtual void GetText( Handle textH, Handle styleH = NULL );
- virtual void Scroll( short delta );
- virtual void DoScroll( short partCode );
-
- virtual void CalScroll();
-
- inline TEHandle GetTextHandle() { return te; };
-
- protected:
- virtual void MakeMacTEAndScroll();
- virtual void PreloadText();
- virtual Boolean PtInScrollbar( const Point mouse );
- };
-
- // these items provide a vertically scrolling textbox, containing the text from a 'TEXT'
- // (and 'styl' if present) resource. The magic string is $$TEXT,id,e where <id> is the res ID
- // of the TEXT/styl resources, and <e> is 0 (or missing) for read-only, 1 for editable. If
- // editable, the keyboard focus will be applied as normal.
-
- #endif